﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "TemporaryDimensionContext.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

namespace gcmp
{
    class TemporaryDimensionContextCreator : public ITemporaryDimensionContextCreator
    {
    public:
        TemporaryDimensionContextCreator() { ITemporaryDimensionContext::RegistTemporaryDimensionContextCreator(this); }
        ~TemporaryDimensionContextCreator() { ITemporaryDimensionContext::RegistTemporaryDimensionContextCreator(nullptr); }

    private:
        virtual OwnerPtr<ITemporaryDimensionContext> CreateLinearDimensionContext(
            const Vector3d& startPt, const Vector3d& endPt,
            bool enableLengthDimension, bool enableAngleDimension,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(LinearTemporaryDimensionContext, startPt, endPt, enableLengthDimension, enableAngleDimension, coord);
        }

        virtual OwnerPtr<ITemporaryDimensionContext> CreateRadiusDimensionContext(
            const Vector3d& startPt, const Vector3d& endPt, const Vector3d& refPt,
            bool enableArcFillet,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(RadiusTemporaryDimensionContext, startPt, endPt, refPt, enableArcFillet, coord);
        }

        virtual OwnerPtr<ITemporaryDimensionContext> CreateCentralAngleDimensionContext(
            const Vector3d& centerPt, const Vector3d& startPt, const Vector3d& endPt, const Vector3d& refPt,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(CentralAngleTemporaryDimensionContext, centerPt, startPt, endPt, refPt, coord);
        }

        virtual OwnerPtr<ITemporaryDimensionContext> CreateRotationDimensionContext(
            const Vector3d& centerPt, const Vector3d& startPt, const Vector3d& endPt,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(RotationTemporaryDimensionContext, centerPt, startPt, endPt, coord);
        }

        virtual OwnerPtr<ITemporaryDimensionContext> CreateRectangleDimensionContext(
            const Vector3d& startPt, const Vector3d& endPt,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(RectangleTemporaryDimensionContext, startPt, endPt, coord);
        }

        virtual OwnerPtr<ITemporaryDimensionContext> CreateTriangleDimensionContext(
            const Vector3d& pt1, const Vector3d& pt2, const Vector3d& pt3,
            const Coordinate3d& coord) override
        {
            return NEW_AS_OWNER_PTR(TriangleTemporaryDimensionContext, pt1, pt2, pt3, coord);
        }
    };

    static TemporaryDimensionContextCreator s_dimensionCreator;
}


